/**
 * @模块名：demo
 * @包名：com.example.http
 * @描述：Test.java
 * @版本：1.0
 * @创建人：李凯
 * @创建时间：2021年2月1日下午2:54:45
 */
package com.example.http;

import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import okhttp3.*;

/**
 * @模块名：demo
 * @包名：com.example.http
 * @类名称：Test
 * @类描述：
 * @版本：1.0
 * @创建人：李凯
 * @创建时间：2021年2月1日下午2:54:45
 */
public class Test {

	public static void main(String[] args) throws IOException {

		X509TrustManager xtm = new X509TrustManager() {
			@Override
			public void checkClientTrusted(X509Certificate[] chain, String authType) {
			}

			@Override
			public void checkServerTrusted(X509Certificate[] chain, String authType) {
			}

			@Override
			public X509Certificate[] getAcceptedIssuers() {
				X509Certificate[] x509Certificates = new X509Certificate[0];
				return x509Certificates;
			}
		};

		SSLContext sslContext = null;
		try {
			sslContext = SSLContext.getInstance("SSL");
			sslContext.init(null, new TrustManager[] { xtm }, new SecureRandom());
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		} catch (KeyManagementException e) {
			e.printStackTrace();
		}

		HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() {
			@Override
			public boolean verify(String hostname, SSLSession session) {
				return true;
			}
		};
		OkHttpClient client = new OkHttpClient().newBuilder().sslSocketFactory(sslContext.getSocketFactory(), xtm)
				.hostnameVerifier(DO_NOT_VERIFY).build();
		RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("merchantNo", "3000000005")
				.addFormDataPart("orderNos", "BZNS202008102239350000000121")
				.addFormDataPart("signData",
						"SmFhCmFXr1VBdrtR6VAwFpdWYJLUe0nnyq1sPWpoXv8XdVj5AbezYsBY6q6uLGZFOqn6WE1yjHZheFkuWFCRqi2sYZS4e+q/Xyf9IIBzZ+OKAcfoaJX8E7H9lbPa6/LNPt23xPj9+yikcaRGvqctn04YsaJGrFmRIUDq0Qra6ZBuhK5RiD1hOJt9GvaItqAmagFXqKZW8En9AcjmHKvvMREqFYuL1a9CaKIdHKRJLXezzauXXVMUIHl73vsmwgRuXEZ4K5Wye4ig73ylNAcqbM8krBSzLWPe92X3hKIslnqrHyod+WPPg4sajnpYC1wUXYrwHqepkUl237Jo1rrsig==")
				.build();
		Request request = new Request.Builder().url("https://www.xjrccb.com.cn/paybank/QueryOrder").method("POST", body)
				.addHeader("Cookie",
						"5MNW14kT87=MDAwM2IyYzgxODAwMDAwMDAwMDIwMWQPDzMxNjEyMTg2ODY2; Q9hctacZDG=MDAwM2IyYzg0YjAwMDAwMDAwMDgwAVtETzkxNjEyMTkwNDcy; jsessionpaybank=jttcOi5fY6qRIV_uzRlKxyTO8f6X3128YVeDr4_PRlErsX7eV2MJ!595902091")
				.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}
